package com.zsrt.java.day20161230.lh.day.demo02;

public class Student02 {
	private int age;
	
	private char sex;

	public int getSex() {
		return sex;
	}

	public void setSex(char sex) {
		if(sex=='男' || sex=='女'){
			this.sex = sex;
		}
		
			
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		if(age>=1 && age<=130){
			
			this.age = age;
		}else{
			this.age = 0;
		}
		
	}

	@Override
	public String toString() {
		System.out.println("调用了tostring的方法");
		return "Student02 [age=" + age + ", sex=" + sex + "]";
	}

}
